package com.heima.model.threadlocal;

import com.heima.model.wemedia.pojos.WmUser;

public class WmThreadLocalUtils {
    //定义一个静态的threadlocal变量
    private final static ThreadLocal<WmUser> wmUserThreadLocal = new ThreadLocal<>();

    /*
    * 设置当前线程的用户id
    * */
    public static void setUserId(WmUser wmUser){
        wmUserThreadLocal.set(wmUser);
    }
    /*
    * 获取当前线程中用户的信息
    * */
    public static WmUser getWmUser(){
        return wmUserThreadLocal.get();
    }
    /*
    * 清除当前线程中用户的信息
    * */
    public static void clearWmUser(){
        wmUserThreadLocal.remove();
    }
}
